// 使用 SWR 的示例
import { RbacRoleType } from '@/data/auth/role';
import { ListResult } from '@/data/result';
import { list } from '@/services/data';
import useSWR from 'swr';

export const useRoles = () => {
  const {
    data: allRoles = [],
    error,
    isLoading,
  } = useSWR('/system/rbacRole', async () => {
    const data: ListResult = await list('/system/rbacRole');
    return data?.list || [];
  });

  return { allRoles: allRoles as RbacRoleType[], isLoading, error };
};
